<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>36.15. syslog — Unix syslog library routines &mdash; Python v2.6.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.6.2',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.6.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v2.6.2 documentation" href="../index.html" />
    <link rel="up" title="36. Unix Specific Services" href="unix.html" />
    <link rel="next" title="36.16. commands — Utilities for running commands" href="commands.html" />
    <link rel="prev" title="36.14. nis — Interface to Sun’s NIS (Yellow Pages)" href="nis.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="commands.html" title="36.16. commands — Utilities for running commands"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="nis.html" title="36.14. nis — Interface to Sun’s NIS (Yellow Pages)"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="unix.html" accesskey="U">36. Unix Specific Services</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-syslog">
<h1>36.15. <tt class="xref docutils literal"><span class="pre">syslog</span></tt> &#8212; Unix syslog library routines<a class="headerlink" href="#module-syslog" title="Permalink to this headline">¶</a></h1>
<p><em>Platforms: </em>Unix</p>
<p>This module provides an interface to the Unix <tt class="docutils literal"><span class="pre">syslog</span></tt> library routines.
Refer to the Unix manual pages for a detailed description of the <tt class="docutils literal"><span class="pre">syslog</span></tt>
facility.</p>
<p>The module defines the following functions:</p>
<dl class="function">
<dt id="syslog.syslog">
<tt class="descclassname">syslog.</tt><tt class="descname">syslog</tt><big>(</big><span class="optional">[</span><em>priority</em><span class="optional">]</span>, <em>message</em><big>)</big><a class="headerlink" href="#syslog.syslog" title="Permalink to this definition">¶</a></dt>
<dd>Send the string <em>message</em> to the system logger.  A trailing newline is added if
necessary.  Each message is tagged with a priority composed of a <em>facility</em> and
a <em>level</em>.  The optional <em>priority</em> argument, which defaults to
<tt class="xref docutils literal"><span class="pre">LOG_INFO</span></tt>, determines the message priority.  If the facility is not
encoded in <em>priority</em> using logical-or (<tt class="docutils literal"><span class="pre">LOG_INFO</span> <span class="pre">|</span> <span class="pre">LOG_USER</span></tt>), the value
given in the <a title="syslog.openlog" class="reference internal" href="#syslog.openlog"><tt class="xref docutils literal"><span class="pre">openlog()</span></tt></a> call is used.</dd></dl>

<dl class="function">
<dt id="syslog.openlog">
<tt class="descclassname">syslog.</tt><tt class="descname">openlog</tt><big>(</big><em>ident</em><span class="optional">[</span>, <em>logopt</em><span class="optional">[</span>, <em>facility</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#syslog.openlog" title="Permalink to this definition">¶</a></dt>
<dd>Logging options other than the defaults can be set by explicitly opening the log
file with <a title="syslog.openlog" class="reference internal" href="#syslog.openlog"><tt class="xref docutils literal"><span class="pre">openlog()</span></tt></a> prior to calling <a title="syslog.syslog" class="reference internal" href="#syslog.syslog"><tt class="xref docutils literal"><span class="pre">syslog()</span></tt></a>.  The defaults are
(usually) <em>ident</em> = <tt class="docutils literal"><span class="pre">'syslog'</span></tt>, <em>logopt</em> = <tt class="docutils literal"><span class="pre">0</span></tt>, <em>facility</em> =
<tt class="xref docutils literal"><span class="pre">LOG_USER</span></tt>.  The <em>ident</em> argument is a string which is prepended to every
message.  The optional <em>logopt</em> argument is a bit field - see below for possible
values to combine.  The optional <em>facility</em> argument sets the default facility
for messages which do not have a facility explicitly encoded.</dd></dl>

<dl class="function">
<dt id="syslog.closelog">
<tt class="descclassname">syslog.</tt><tt class="descname">closelog</tt><big>(</big><big>)</big><a class="headerlink" href="#syslog.closelog" title="Permalink to this definition">¶</a></dt>
<dd>Close the log file.</dd></dl>

<dl class="function">
<dt id="syslog.setlogmask">
<tt class="descclassname">syslog.</tt><tt class="descname">setlogmask</tt><big>(</big><em>maskpri</em><big>)</big><a class="headerlink" href="#syslog.setlogmask" title="Permalink to this definition">¶</a></dt>
<dd>Set the priority mask to <em>maskpri</em> and return the previous mask value.  Calls to
<a title="syslog.syslog" class="reference internal" href="#syslog.syslog"><tt class="xref docutils literal"><span class="pre">syslog()</span></tt></a> with a priority level not set in <em>maskpri</em> are ignored.  The
default is to log all priorities.  The function <tt class="docutils literal"><span class="pre">LOG_MASK(pri)</span></tt> calculates the
mask for the individual priority <em>pri</em>.  The function <tt class="docutils literal"><span class="pre">LOG_UPTO(pri)</span></tt>
calculates the mask for all priorities up to and including <em>pri</em>.</dd></dl>

<p>The module defines the following constants:</p>
<dl class="docutils">
<dt>Priority levels (high to low):</dt>
<dd><tt class="xref docutils literal"><span class="pre">LOG_EMERG</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_ALERT</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_CRIT</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_ERR</span></tt>,
<tt class="xref docutils literal"><span class="pre">LOG_WARNING</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_NOTICE</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_INFO</span></tt>,
<tt class="xref docutils literal"><span class="pre">LOG_DEBUG</span></tt>.</dd>
<dt>Facilities:</dt>
<dd><tt class="xref docutils literal"><span class="pre">LOG_KERN</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_USER</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_MAIL</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_DAEMON</span></tt>,
<tt class="xref docutils literal"><span class="pre">LOG_AUTH</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_LPR</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_NEWS</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_UUCP</span></tt>,
<tt class="xref docutils literal"><span class="pre">LOG_CRON</span></tt> and <tt class="xref docutils literal"><span class="pre">LOG_LOCAL0</span></tt> to <tt class="xref docutils literal"><span class="pre">LOG_LOCAL7</span></tt>.</dd>
<dt>Log options:</dt>
<dd><tt class="xref docutils literal"><span class="pre">LOG_PID</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_CONS</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_NDELAY</span></tt>, <tt class="xref docutils literal"><span class="pre">LOG_NOWAIT</span></tt>
and <tt class="xref docutils literal"><span class="pre">LOG_PERROR</span></tt> if defined in <tt class="docutils literal"><span class="pre">&lt;syslog.h&gt;</span></tt>.</dd>
</dl>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="nis.html"
                                  title="previous chapter">36.14. <tt class="docutils literal docutils literal docutils literal"><span class="pre">nis</span></tt> &#8212; Interface to Sun&#8217;s NIS (Yellow Pages)</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="commands.html"
                                  title="next chapter">36.16. <tt class="docutils literal docutils literal docutils literal"><span class="pre">commands</span></tt> &#8212; Utilities for running commands</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/library/syslog.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="commands.html" title="36.16. commands — Utilities for running commands"
             >next</a> |</li>
        <li class="right" >
          <a href="nis.html" title="36.14. nis — Interface to Sun’s NIS (Yellow Pages)"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="unix.html" >36. Unix Specific Services</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; <a href="../copyright.html">Copyright</a> 1990-2009, Python Software Foundation.
      Last updated on Apr 15, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
    </div>
  </body>
</html>